//
//  BPProductHeadInfoView.m
//  BeautyPicture
//
//  Created by 沈振邦 on 15/10/23.
//  Copyright (c) 2015年 szb. All rights reserved.
//

#import "BPDetailHeadInfoView.h"
#import "BPImageTool.h"

@implementation BPDetailHeadInfoView

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [UIColor whiteColor];
        
        //1.设置背景imageview的位置
        _productImage = [[UIImageView alloc] initWithFrame:self.bounds];
        [self addSubview:_productImage];
        //2.设置infoview的位置
        CGFloat infoH = 40.0f;
        UIView *infoView = [[UIView alloc] initWithFrame:CGRectMake(0, self.height - infoH, self.width, infoH)];
        infoView.backgroundColor = BPGlobaBGColor;
        infoView.alpha = 0.5;
        [self addSubview: infoView];
        
        //3.设置产品名称位置
        CGFloat labelY = infoView.y + 5;
        CGFloat labelH = infoH - 10;
        _productName = [[UILabel alloc] initWithFrame:CGRectMake(BPStatusCellInset, labelY, 100, labelH)];
        _productName.textColor = BPGlobaThemeColor;
        _productName.font = [UIFont boldSystemFontOfSize:17.0f];
        [self addSubview:_productName];
        
        //4.设置产品规格
        CGFloat slabX = CGRectGetMaxX(_productName.frame);
        _Standard = [[UILabel alloc] initWithFrame:CGRectMake(slabX + 10, labelY, 100, labelH)];
        _Standard.textColor = [UIColor grayColor];
        _Standard.font = [UIFont systemFontOfSize:13.0f];
        [self addSubview:_Standard];
        
        //5.设置页数
        CGFloat pLabX = CGRectGetMaxX(_Standard.frame);
        _PageCount = [[UILabel alloc] initWithFrame:CGRectMake(pLabX + 10, labelY, 90, labelH)];
        _PageCount.textColor = [UIColor grayColor];
        _PageCount.font = [UIFont systemFontOfSize:13.0f];
        [self addSubview:_PageCount];

    }
    return self;
}

- (void)addProductData:(BPProductDetail *)productInfo
{
    [BPImageTool setUpHDImageView:self.productImage addNsstringUrl:productInfo.xiaoguo];
    self.Standard.text = [NSString stringWithFormat:@"规格：%@",productInfo.cover_standard];
    self.PageCount.text = [NSString stringWithFormat:@"页数：%lu页",(unsigned long)productInfo.pages.count];
    self.productName.text = productInfo.title;
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
